# coding=utf-8

# str()： 函数返回一个用户易读的表达形式。
# repr()： 产生一个解释器易读的表达形式。
def printdemo():
    s = 'Hello, Runoob'
    print(str(s))
    print(repr(s))
    print(str(1 / 7))
    print(1 / 7)

    x = 10 * 3.25
    y = 200 * 200
    s = 'x 的值为： ' + repr(x) + ',  y 的值为：' + repr(y) + '...'
    print(s)
    #  repr() 函数可以转义字符串中的特殊字符
    hello = 'hello, runoob\n'
    print(repr(hello))
    print(hello)

    # 两种方式输出一个平方与立方的表:
    for x in range(1, 11):
        print(repr(x).rjust(2), repr(x * x).rjust(3), end=' ')
        # 注意前一行 'end' 的使用
        print(repr(x * x * x).rjust(4))

    print("====================")

    for x in range(1, 11):
        print('{0:2d} {1:3d} {2:4d}'.format(x, x * x, x * x * x))

    print('12'.zfill(5))
    print('-3.14'.zfill(7))
    print('3.14159265359'.zfill(5))


# open(file, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
def outputdemo():
    f = open("ceshi.txt", "w", encoding='utf-8')
    f.write("Python 是一个非常好的语言。\n是的，的确非常好!!\n")
    # 关闭打开的文件
    f.close()


def intputdemo():
    f = open("ceshi.txt", "r", encoding='utf-8')
    data = f.read()
    data01 = f.readline()
    print(data)
    print(data01)
    f.close()


def intputdemo1():
    f = open("ceshi.txt", "r", encoding='utf-8')
    data01 = f.readline()
    print(data01)
    f.close()


def intputdemo2():
    f = open("ceshi.txt", "r", encoding='utf-8')
    data01 = f.readlines()
    print(data01)
    f.close()


def intputdemo03():
    f = open("ceshi.txt", "r", encoding='utf-8')
    for line in f:
        print(line, end="")
    f.close()


def inputdemo04():
    f = open("ceshi01.txt", "w", encoding='utf-8')
    value = ('www.runoob.com', 14)
    s = str(value)
    f.write(s)
    print(f.tell())
    print(f.seek(4))
    f.close()



inputdemo04()
